package bpm.domain.archive;

import java.io.Serializable;

/**
 * 
 * @author <a mailto="hwangsyin@gmail.com">King</a>
 *
 */
public class ArchiveEntryView implements Serializable {
	private static final long serialVersionUID = 1L;
	
	public String id;
	public String archiveId;
	public String documentId;
	public String type;
	public String referedId;
	public String entryName;
	public String entryType;
	public String entryValue;
	
	public ArchiveEntryView() {}
	public ArchiveEntryView(ArchiveItem item) {
		if(item != null) {
			this.id = item.getId();
			this.type = item.getType().name();
			this.referedId = item.getField().getDocumentField().getKey();
			this.entryName = item.getField().getKey();
			this.entryType = item.getField().getDataType();
			this.entryValue = item.getValue();
		}
	}
	public ArchiveEntryView(ArchiveAttach attach) {
		if(attach != null) {
			this.id = attach.getId();
			this.type = attach.getType().name();
			this.referedId = attach.getReferedAttachmentId();
			this.entryName = attach.getName();
			this.entryType = attach.getExtension();
			this.entryValue = attach.getMainName();
		}
	}
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("id: ").append(id)
			.append(", archiveId: ").append(archiveId)
			.append(", documentId: ").append(documentId)
			.append(", type: ").append(type)
			.append(", referedId: ").append(referedId)
			.append(", entryName: ").append(entryName)
			.append(", entryType: ").append(entryType)
			.append(", entryValue: ").append(entryValue);
		return sb.toString();
	}
}
